home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
rjs.lha
/
RJS
/
Transport
/
src
/
UnixAddress.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-06-14
|
1KB
|
62 lines
#include <stdio.h>
#include <osfcn.h>
#include <libc.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <iostream.h>
#include "Transport.h"
extern "C" {
unsigned long htonl(unsigned long);
unsigned short htons(unsigned short);
unsigned short ntohs(unsigned short);
struct hostent *gethostbyname(const char *host);
}
char *RJS_UnixAddress::Temp="";
const RJS_Status RJS_UnixAddress::NoPathGiven("no path given");
ostream &operator<<(ostream &os, const RJS_UnixAddress &ia)
{
os << "(" << ia.pathname() << ")";
return os;
}
RJS_UnixAddress::RJS_UnixAddress()
{
ss_set(NoPathGiven);
addrlen=sizeof(address);
bzero((char *) &address, sizeof(address));
address.sun_family = RJS_Socket::AfUnix;
strcpy(address.sun_path,"");
addrlen = sizeof(address.sun_family);
}
RJS_UnixAddress::RJS_UnixAddress(const char *pathname)
{
set(pathname);
}
void RJS_UnixAddress::set(const char *pathname)
{
bzero((char *) &address, sizeof(address));
address.sun_family = RJS_Socket::AfUnix;
if (pathname==Temp) {
strcpy(address.sun_path,tmpnam(NULL));
} else strcpy(address.sun_path,pathname);
addrlen = strlen(pathname) + sizeof(address.sun_family);
}
const char *RJS_UnixAddress::pathname() const
{
address.sun_path[addrlen-sizeof(address.sun_family)] = 0;
return address.sun_path;
}